export default function (
  data: any,
  codeField = 'adcode',
  nameField = 'name'
): any {
  return data
    .map((item: any) => ({
      ...item,
      ...switchData(
        codeField ? item[codeField] : item[nameField],
        codeField,
        nameField
      )
    }))
    .filter((item: any) => item.isShow)
}

const switchData = (
  field: string,
  codeField: string,
  nameField: string
): any => {
  const result: any = { isShow: true }
  switch (field) {
    case '1':
    case '2':
      result[codeField] = ''
      result[nameField] = ''
      break

    default:
      result.isShow = false
      break
  }
  return result
}

// import qhCodeSwitch from '@/utils/qhCode'
